package com.buaa.utility.services;

import java.util.Map;
import java.util.ResourceBundle;

public class ServicesFactory {
	
	public static final String DBKEYNAME = "dbkeyname";
	
	public static DBService getDBService(Map p){
		String prefix = "default";
		if(p!=null){
			if(p.get(DBKEYNAME)!=null){
				prefix = p.get(DBKEYNAME).toString().toLowerCase();
			}
		}
		String username = SystemConfiguration.getSystemProperty(prefix+".username");
		String password = SystemConfiguration.getSystemProperty(prefix+".password");
		String url = SystemConfiguration.getSystemProperty(prefix+".url");
		String driver = SystemConfiguration.getSystemProperty(prefix+".driver");
		return new DataSourceDBService(username,password,url,driver);
	}
}
